#include"UASSpritePool.h"

//	Here we load all need sprite & texture.When we use , we get them from pool.
//	If all sprite & texture use too large memory ,we should modfiy code structure here.
UASSpritePool::UASSpritePool()
{
	for(int idx = ESFI_GANGSTAR_MAN;idx < ESFI_MAX ; ++idx)
	{
		_spriteList.push_back(NULL);
	}

	//	temp only get 2 sprites
	UASSprite* pCurSprite = NULL;
	extern IDirect3DDevice9 *g_pd3dDevice;
	
	pCurSprite = new UASSprite(g_pd3dDevice,"..\\content\\character_man.png");
	pCurSprite->LoadAuroraSprite("..\\content\\character_man.sprite");
	_spriteList[ESFI_GANGSTAR_MAN] = pCurSprite;

	pCurSprite = new UASSprite(g_pd3dDevice,"..\\content\\HUD_43.tga");
	pCurSprite->LoadAuroraSprite("..\\content\\HUD_43.sprite");
	_spriteList[ESFI_AOW_HUD] = pCurSprite;



	//ESFI_GANGSTAR_MAN,
	//ESFI_AOW_HUD,
	//ESFI_ICEAGE_DDS,
	//ESFI_MAX,

}

UASSpritePool::~UASSpritePool()
{
	for(vector<UASSprite*>::iterator it = _spriteList.begin();it < _spriteList.end();++it)
	{
		if((*it)!=NULL)
		{
			delete (*it);
			(*it) = NULL;
		}
	}
	_spriteList.clear();
}


UASSprite* const UASSpritePool::GetSpriteById(ESpriteFileIdx spriteId) const
{
	if(spriteId < int(_spriteList.size()))
	{
		return _spriteList[spriteId];
	}
	return NULL;
}